package com.fr.cell.core;

import javax.swing.DefaultListModel;
import javax.swing.JList;

public class DataGUIUtils
{
  public static void removeSelectedListItems(JList paramJList)
  {
    int j;
    int i = paramJList.getSelectedIndex();
    Object[] arrayOfObject = paramJList.getSelectedValues();
    DefaultListModel localDefaultListModel = (DefaultListModel)paramJList.getModel();
    if (localDefaultListModel.size() > 0)
      for (j = arrayOfObject.length - 1; j >= 0; --j)
        localDefaultListModel.removeElement(arrayOfObject[j]);
    if (i >= 0)
      if (i >= localDefaultListModel.size())
        paramJList.setSelectedIndex(localDefaultListModel.size() - 1);
      else
        paramJList.setSelectedIndex(i);
  }

  public static void removeAllListItems(JList paramJList)
  {
    DefaultListModel localDefaultListModel = (DefaultListModel)paramJList.getModel();
    localDefaultListModel.removeAllElements();
  }

  public static void upListSelectedIndex(JList paramJList)
  {
    int i = paramJList.getSelectedIndex();
    DefaultListModel localDefaultListModel = (DefaultListModel)paramJList.getModel();
    Object localObject1 = localDefaultListModel.get(i);
    Object localObject2 = localDefaultListModel.get(i - 1);
    localDefaultListModel.set(i, localObject2);
    localDefaultListModel.set(i - 1, localObject1);
    paramJList.setSelectedIndex(i - 1);
    paramJList.ensureIndexIsVisible(paramJList.getSelectedIndex());
  }

  public static void downListSelectedIndex(JList paramJList)
  {
    int i = paramJList.getSelectedIndex();
    DefaultListModel localDefaultListModel = (DefaultListModel)paramJList.getModel();
    Object localObject1 = localDefaultListModel.get(i);
    Object localObject2 = localDefaultListModel.get(i + 1);
    localDefaultListModel.set(i, localObject2);
    localDefaultListModel.set(i + 1, localObject1);
    paramJList.setSelectedIndex(i + 1);
    paramJList.ensureIndexIsVisible(paramJList.getSelectedIndex());
  }
}